package com.vecspace.dayu.code.source.httphandler;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.vecspace.dayu.code.source.model.SourceCode;
import com.vecspace.dayu.code.source.service.SourceCodeService;
import com.vecspace.security.model.LoginContext;
import com.vecspace.web.servlet.model.BaseController;
import com.vecspace.web.servlet.model.HController;
import com.vecspace.web.servlet.model.Param;
import com.vecspace.web.servlet.model.Path;

@HController("dayucode_sourceCodeHandler")
public class SourceCodeHandler extends BaseController {
	/**生成一个功能的源代码
	 * 
	 * @param funcId
	 * @param terminalType
	 * @param codeType  SourceCodeType: DAYU-CODE-031 java, vue, app, pad
	 * @return
	 * @throws Exception 
	 * @author wanghua
	 */
	@Path("generateCodes")
	public List<SourceCode> generateCodes(@Param("funcId")Long funcId, @Param("terminalType")String terminalType, @Param("pageLayoutId")Long pageLayoutId, @Param("codeType")String codeType) throws Exception{
		String loginId = LoginContext.getLoginId();
		if(StringUtils.isBlank(loginId))loginId = "user";
		return sourceCodeService.generateCodes(funcId, terminalType, pageLayoutId, codeType, loginId);
	}


	@Autowired
	private SourceCodeService sourceCodeService;
}
